#include <qwt_plot.h>
#include <vector>
//#include "see.h"

using namespace std;

class ColorBar;
class QwtWheel;
class QWidget;
class QwtPlotCurve;
class QSlider;
class tStation;
class QCloseEvent;

#ifndef _eLT
#define _eLT
enum eLT{eNone,eThr1,eThr2,eToT};
#endif


class pDetector: public QwtPlot
{
    Q_OBJECT
  public:
    pDetector(QWidget *parent = NULL);
    pDetector(vector<tStation>* statList,QWidget *parent = NULL);
    virtual bool eventFilter(QObject *, QEvent *);
    
  public slots:
    void setCanvasColor(const QColor &);
    void paintDetector(vector<tStation>* statList);
    void externalTankSelect(int sId,eLT lt);

  private slots:
    void selectTank(int curveId,int index);
  
  signals:
    void newTankId(QwtPlotCurve* curve,int index);
    void changedTank(int sId);

  private:
    void insertCurve(Qt::Orientation, const QColor &, double base);
    QwtPlotCurve *zeroCu;
    QwtPlotCurve *totCu;
    QwtPlotCurve *thr2Cu;
    QwtPlotCurve *thr1Cu;
    vector<int> zeroIndex;
    vector<int> totIndex;
    vector<int> thr2Index;
    vector<int> thr1Index;
};


class wDet: public QWidget
{
  Q_OBJECT
  
  public:
    wDet(QWidget *parent = 0);
    wDet(vector<tStation>* statList,QWidget *parent = 0);
    
  signals:
    void paintDetector(vector<tStation>* statList);
    void externalTankSelect(int sId,eLT lt);
    void changedTank(int sId);
    void openWindow(bool);

  protected:
    void closeEvent(QCloseEvent *event);
    
  public slots:
    void newDetector(vector<tStation>* statList);
    void tankSelect(int sId,eLT lt);
    
  private slots:
    void moveHPlot(double value);
    void moveVPlot(double value);
    void rescalePlot(int value);
    
  private:
    pDetector* detPlot;
    QSlider* zoom;
    QwtWheel* hRuedita;
    QwtWheel* vRuedita;
    double minX;
    double maxX;
    double minY;
    double maxY;
    double xMean;
    double yMean;
    double xDetMean;
    double yDetMean;
    double xRadio;
    double yRadio;
    double xMaxRadio;
    double yMaxRadio;
};

